package com.qdaily.ui.ui;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.qdaily.ui.QDBaseActivity;
import com.qdaily.ui.R;
import com.qdaily.ui.util.QDTestServerSetHelper;

/**
 * Created by song on 15/5/14.
 * 能进这个界面，肯定是测试版本
 */
public class DeveloperActivity extends QDBaseActivity{
    private EditText dev_edittext;
    private TextView dev_curip;
    private Button dev_btn1;
    private Button dev_btn2;
    private Button dev_btn3;
    private CheckBox dev_checkBox;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_developer);
        dev_curip = (TextView) this.findViewById(R.id.dev_curip);
        dev_edittext = (EditText) this.findViewById(R.id.dev_edittext);
        dev_btn1 = (Button) this.findViewById(R.id.dev_btn1);
        dev_btn2 = (Button) this.findViewById(R.id.dev_btn2);
        dev_btn3 = (Button) this.findViewById(R.id.dev_btn3);
        dev_checkBox = (CheckBox) this.findViewById(R.id.dev_checkBox);

        dev_curip.setText("当前服务器地址:" + QDTestServerSetHelper.getServerIp());
        dev_checkBox.setChecked(QDTestServerSetHelper.getInstance().isUseTestServer());

        dev_btn1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                QDTestServerSetHelper.getInstance().setTestServer(dev_checkBox.isChecked(), "http://42.121.104.18:10002/");
            }
        });
        dev_btn2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                String text = dev_edittext.getText().toString();
                if (!TextUtils.isEmpty(text))
                {
                    QDTestServerSetHelper.getInstance().setTestServer(dev_checkBox.isChecked(), text);
                }
            }
        });
        dev_btn3.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                QDTestServerSetHelper.getInstance().setTestServer(false, "");
            }
        });
    }
}
